<?php
/* Variables can easily be passed page to page using the built in $_SESSION array. 
   If you try to start the session more than once, you get warnings -- so we check
   if it's been started already. */
if(!isset($_SESSION))
{
  session_start();
}

/* Displays PHP errors.  Good for debugging and developing, but we need to remove
   these when we go live so customers don't see errors and h4xx0rs don't gain info
   about our back-end code. */
error_reporting(E_ALL);
ini_set('display_errors', '1');

/* Include a connection to the database in a sort of roundabout but secure(ish) way */
include_once("includes/config.inc.php");
include_once(MYSQL);

/* If $_SESSION['email'] is set, that means a user is logged in -- so we'll have to
   customize a few things on the page.  We need to change the (create account | login)
   to say (login@email.com | logout) */
if(isset($_SESSION['email']))
{
  $user = $_SESSION['email'];
}

?>

<!doctype HTML>

<html lang="en">

<head>

  <title>Grapevine</title>
  <link rel="stylesheet" type="text/css" href="css/normalize.css" />
  <link rel="icon" type="image/png" href="images/favicon.png" />
  <meta charset="utf-8"/>

  <!--[if lt IE 9]>
  <script src="js/html5shiv.js"></script>
  <![endif]-->
  
  <style>
  body
  {
    background-image:url('images/background.png');
  }
  #header
  {
   	width: 100%;
    background-color: #5f0808;
    color: #f9f9f9;
  }
  #navigation
  {
    width: 1000px;
    height: 75px;
    margin: 0 auto;
  }
  #navigation ul
  {
    list-style-type: none;
    float: left;
  }
  #navigation li
  {
    display: inline-block;
    text-align: center;
    width: 100px;
    height: 75px;
    line-height: 45px;
    font-size:110%;
  }
  #navigation img
  {
    float: left;
    margin-top: 4px;
  }
  #navigation form
  {
    float: right;
    margin-top: 25px;
  }
  #navigation input
  {
    width: 250px;
  }
  #navigation a
  {
    text-decoration: none;
    color: #f9f9f9;
    display: block;
  }
  #navigation a:hover
  {
   
  }

  #login_container
  {
    width: 1000px;
    margin: 0 auto;
  }
  #login
  {
    height: 25px;
    float: right;
    background-color: #f9f9f9;
    border-left: 1px solid #5f0808;
    border-right: 1px solid #5f0808;
    border-bottom: 1px solid #5f0808;
    border-bottom-left-radius: 5px;
    border-bottom-right-radius: 5px;
    text-align: center;
    font-size: 85%;
    padding-left:4px;
    padding-right:4px;
  }
  
  #login p
  {
    margin-top: 4px;
  }
  #login a
  {
    text-decoration: none;
    color:#1e1e1e;
  }
  #page_container
  {
    margin: 0 auto;
    width: 950px;
  }
  #footer
  {
    margin: 40px auto;
    width: 1000px;
    border-top: 1px solid #999999;
    text-align: center;
    font-size: 70%;
  }
  #footer a
  {
    text-decoration: none;
    color: #1e1e1e;
  }
  #footer img
  {
    margin-top: 10px;
  }
   
  </style>

</head>

<body>
  <div id="header">
    <div id="navigation">
      <a href="index.php"><img src="images/grapevinelogobigg.png" alt="Grapevine logo" /></a>
      <ul>
        <li><a href="index.php">Welcome</a></li>
        <li><a href="search.php">Search</a></li>
        <li><a href="status.php">Status</a></li>
        <li><a href="about.php">About</a></li>
      </ul>
      <form action="php/search_handler.php" method="GET">
        <input type="search" name="searchInput" results="3" placeholder="Search for local vineyards" autofocus />
      </form>
    </div>
  </div>
  <div id="login_container">
    <div id="login">
      
      <?php 

      /* 
      * Displays the users login name instead of 'Create Account' If the user
      * Is logged in. 
      */
      if(isset($user))
      {
        echo "<p><a href=\"status.php\">" . $user . "</a> | ";  
        echo "<a href=\"php/logout.php\">logout</a></p>";
      }
      else
      {
      	echo "<p><a href=\"login.php\">Login</a> | ";
        echo "<a href=\"create_account.php\">Create Account</a></p>"; 
      }

      ?>
      
    </div>
  </div>

<div id="page_container">
  <div style="clear:both"></div>

